<%@ page import="vo.Teacher" %>
<%@ page import="vo.Score" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="dao.StudentD" %>
<%@ page import="java.io.File" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="../resources/css/bootstrap.min.css">
    <title>学生成绩管理</title>
    <link href="../resources/css/default.css" rel="stylesheet"/>
</head>
<body>
<%@include file="../Util.jsp"%>
<%
    Teacher teacher = (Teacher) session.getAttribute("info");
    ArrayList<Score> stus = (ArrayList<Score>) session.getAttribute("onePageScore");
    int sumIndex = (int) session.getAttribute("sumScoreIndex");
    int currentIndex = (int) session.getAttribute("currentScoreIndex");
    String imgPath = "default";
    try {
        String path = "D:\\code\\2024\\Project\\StuddentManager\\web\\userImg";
        String name = teacher.getId() + ".jpg";
        File imgFile = new File(path,name);
        if (imgFile.exists()) {
            imgPath = teacher.getId();
        }
    } catch (Exception e) {
        out.print(e);
    }
%>
<div id="page" class="mycontainer">
    <div id="header">
        <div id="logo">
            <img src="../userImg/<%=imgPath%>.jpg"/>
            <h1><%=teacher.getId()%></h1>
        </div>
        <div id="menu">
            <ul>
                <li><a href="personal.jsp">个人信息</a></li>
                <li><a href="../one_page_student">学生管理</a></li>
                <li class="current_page_item"><a href="../one_page_score">成绩管理</a></li>
                <li><a onclick="return confirm('确认退出?');" href="../exit">退出登录</a></li>
            </ul>
        </div>
    </div>
    <div id="main">
        <div class="top">
            <h2>学生成绩管理</h2>
            <hr/>
        </div>
        <form method="post" action="../update_score" style=" height: 650px;margin-top: -10px">
            <input type="button" class="btn-add" onclick="location.href='score_excel.jsp';" value="导出EXCEL">
            <input type="submit" class="btn-add" style="float: right;margin-bottom: 30px" value="修改">
            <div class="table" style="margin-top: 20px; height: 525px">
                <table id="table"  frame="box" align="center">
                    <tr>
                        <th height="35">学号</th>
                        <th>姓名</th>
                        <th>专业</th>
                        <th>DataBase</th>
                        <th>Android</th>
                        <th>JavaWeb</th>
                    </tr>
                    <%
                        try {
                            StudentD stuD = new StudentD();
                            for (Score stu : stus) {
                                String name = stuD.findWithId(stu.getId()).getName();
                                String major = stuD.findWithId(stu.getId()).getMajor();
                    %>
                                <tr>
                                    <td height="35"><%=stu.getId()%></td>
                                    <td><%=name%></td>
                                    <td><%=major%></td>
                                    <td><input value="<%=stu.getDatabase()%>" name="database" class="table-input"></td>
                                    <td><input value="<%=stu.getAndroid()%>" name="android" class="table-input"></td>
                                    <td><input value="<%=stu.getJsp()%>" name="jsp" class="table-input"></td>
                                    <input value="<%=stu.getId()%>" name="id" type="hidden">
                                </tr>
                    <%
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    %>
                </table>

            </div>
        </form>
        <div id="index">
            <a href="../one_page_score?index=1">首页</a>
            <a href="../one_page_score?index=<%=(currentIndex-1<1?1:currentIndex-1)%>">上一页</a>
            <a href="../one_page_score?index=<%=(currentIndex+1>sumIndex?sumIndex:currentIndex+1)%>">下一页</a>
            <a href="../one_page_score?index=<%=sumIndex%>">尾页</a>
        </div>
    </div>
</div>
</body>
</html>
